//
//  AppDelegate.m
//  IMSDKDemo
//
//  Created by FungYan on 2022/5/5.
//

#import "AppDelegate.h"
#import "LoginViewController.h"
#import "HomeViewController.h"
#import "WeCloudIMSDK/WeCloudIMSDK.h"
@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
   
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"isInRoom"];
    [[WeCloudIMClient sharedWeCloudIM] initServiceHttpUrl:@"https://imapitest.wecloud.cn/" wsUrl:@"wss://imapitest.wecloud.cn/ws"];
    
    if ([WeCloudIMClient sharedWeCloudIM].isLogin) {
        [[WeCloudIMClient sharedWeCloudIM] openWithCallback:^(BOOL isAutoOpen, NSDictionary * _Nonnull resultDic) {
            NSLog(@"登入成功");
        }];
        HomeViewController *home = [[HomeViewController alloc]init];
        home.title = @"已登录成功";
        UINavigationController *nav= [[UINavigationController alloc]initWithRootViewController:home];
        
        self.window.rootViewController = nav;
        [self.window makeKeyAndVisible];
     
    } else {
        LoginViewController *login = [[LoginViewController alloc]init];
        self.window.rootViewController = login;
        [self.window makeKeyAndVisible];
    }
    return YES;
}



@end
